//=============================================================================
// TFMDFire.
//=============================================================================
class TFMDFire extends TFProjectileFire
	placeable;

function DoFireEffect()
{
    local Vector StartProj, StartTrace, X,Y,Z;
//    local Rotator Aim;
    local Vector HitLocation, HitNormal;
    local Actor Other;
	local pawn p;
	local int i, irand;
	local coords bcor;
    local vector vec;
    local TFMDBeamFX fx;
    local float amount;

    Instigator.MakeNoise(1.0);
    Weapon.GetViewAxes(X,Y,Z);

    StartTrace = Instigator.Location + Instigator.EyePosition();
    StartProj = StartTrace + X*ProjSpawnOffset.X + Y*ProjSpawnOffset.Y;

    Other = Trace(HitLocation, HitNormal, StartProj, StartTrace, true);
    if(pawn(Other)!=None && pawn(Other).Health>0 && pawn(other).playerreplicationinfo!=none && pawn(other).playerreplicationinfo.team.teamindex==instigator.playerreplicationinfo.team.teamindex)
        p=pawn(other);
    else p=instigator;


    amount=fmin(6, weapon.AmmoAmount(0)*6);
    if(p==instigator) amount/=2;
    if(p.health>100) amount/=3;
    amount=fmin(amount, 199-p.health);

    p.Health+=amount;

    if(amount>0)
    {
        Weapon.ConsumeAmmo(0, 1);
        Instigator.PlaySound(Sound'TFMedia.tfMDFire',SLOT_None,TransientSoundVolume*1,,,0.7+frand()*0.3);

        if(frand()<0.3) p.Spawn(class'Taskforces.TFShieldHealFX');

        if(p.controller!=none && playercontroller(p.controller)!=none)
            playercontroller(p.controller).clientflash(0.4, vect(0,1600,1200)*(amount/6));

        if(p!=instigator)
        {
            for(i=0; i<1 +rand(5); i++)
            {
                irand=rand(7);

                if(irand==0) {BCor = p.GetBoneCoords('Bip01 Head'); vec = BCor.Origin;}
                else if(irand==1) {BCor = p.GetBoneCoords('Bip01 L Hand'); vec = BCor.Origin;}
                else if(irand==2) {BCor = p.GetBoneCoords('Bip01 R Hand'); vec = BCor.Origin;}
                else if(irand==3) {BCor = p.GetBoneCoords('Bip01 Pelvis'); vec = BCor.Origin;}
                else if(irand==4) {BCor = p.GetBoneCoords('Bip01 L Foot'); vec = BCor.Origin;}
                else if(irand==5) {BCor = p.GetBoneCoords('Bip01 R Foot'); vec = BCor.Origin;}
                else {BCor = p.GetBoneCoords('Bip01 Spine1'); vec = BCor.Origin;}

                if(vec!=vect(0,0,0))
                {
	                fx=Spawn(class'Taskforces.TFMDBeamFX',,,vec);
	                fx.SetBase(p);
                    fx.mSpawnVecA=starttrace +8*y -5*z;
	            }
	        }
	    }
    }
}

defaultproperties
{
     ProjSpawnOffset=(X=150.000000,Y=8.000000)
     bLeadTarget=False
     bModeExclusive=False
     TransientSoundVolume=0.750000
     FireRate=0.300000
     AmmoClass=Class'taskforces.TFMDAmmo'
}
